/**
 * @file ScrollToTop.jsx
 * @description 路由切换时滚动到页面顶部的组件。
 */
import { useEffect } from "react";
import { useLocation } from "react-router-dom";

const ScrollToTop = ({ children }) => {
  const { pathname } = useLocation();

  useEffect(() => {
    window.scrollTo(0, 0);
  }, [pathname]);

  return children || null; 
};

export default ScrollToTop;